#Variables
Clear-Host

$hi="Hello world"
$hi

Write-Host $hi
#Variables are objects
$hi.GetType()

# Display all the members of this variable 
$hi | Get-Member

# Use some of those members
$hi.ToUpper()
$hi.ToLower()
$hi.Length

# Types are mutable
Clear-Host
$hi=5
$hi.GetType()
$hi | Get-Member

# Varaibles can be strongly typed
Clear-Host

[System.Int32]$myInt=42
$myInt
$myInt.GetType()
$myInt="This won't work"

# There are shortcuts for most .net types
Clear-Host
[int] $myotherint=42
$myotherint.GetType()

[string]$mystring="PowerShell"
$mystring.GetType()

# others include short, float, decimal, single, bool, byte, etc

# Not just variables have types - so do static values
"PowerShelll Rocks".GetType()

# Accessing methods on objects
"PowerShell Rocks".ToUpper()
"PowerShell Rocks".Contains("PowerShell")

# For nonstrings you need to wrap in () so pS will evaluate as an object
(33).GetType()

# Comparisons
$var=33

$var -gt 30
$var -lt 30
$var -eq 33

# List is:
# -eq Equals
# -ne Not equal to
# -lt Less than
# -gt Greater than
# -le Less than or equal to
# -ge Greater than or equal to
# -in See if value in an array
# -notin See if a value is missing from an array
# -Like Like wildcard pattern matching
# -NotLike Not Like
# -Match Matches based on regular expressions
# -NotMatch Non-Matches based on regular expressions

# Calculations are like any other language
$var =3*11
$var

# Supports post unary operators ++ and --
$var ++
$var

# And pre unary operators as well
++$var
$var

# Be cautious of Implicit Type Conversions
"42" -eq 42
42 -eq "42"

# False and true
$false
$true

# Null
$null

# Current directory
$PWD

# Users Home Directory
$HOME

# Info about a users scripting environment
$Host

# Process ID
$PID

# Info about the current version of PowerShell
$PSVersionTable

$_ #Current Object

Set-Location "C:\Code\LearningPowerShell\Grammars\BeginningScripts"
Get-ChildItem | Where-Object {$_.Name -like "*.ps1"}

